package com.sdhs.projectschedule.controller;

import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.core.page.TableDataInfo;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.common.utils.poi.ExcelUtil;
import com.sdhs.projectschedule.domain.GcProgressProjectEnd;
import com.sdhs.projectschedule.service.IGcProgressProjectEndService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 项目进度控制--项目结束Controller
 *
 * @author andong
 * @date 2025-04-29
 */
@RestController
@RequestMapping("/progress/projectEnd")
public class GcProgressProjectEndController extends BaseController {
    @Autowired
    private IGcProgressProjectEndService gcProgressProjectEndService;

    /**
     * 查询项目进度控制--项目结束列表
     */
    @PreAuthorize("@ss.hasPermi('projectschedule:projectEnd:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcProgressProjectEnd gcProgressProjectEnd) {
        startPage();
        List<GcProgressProjectEnd> list = gcProgressProjectEndService.selectGcProgressProjectEndList(gcProgressProjectEnd);
        return getDataTable(list);
    }

    /**
     * 导出项目进度控制--项目结束列表
     */
    @PreAuthorize("@ss.hasPermi('projectschedule:projectEnd:export')")
    @Log(title = "项目进度控制--项目结束", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcProgressProjectEnd gcProgressProjectEnd) {
        List<GcProgressProjectEnd> list = gcProgressProjectEndService.selectGcProgressProjectEndList(gcProgressProjectEnd);
        ExcelUtil<GcProgressProjectEnd> util = new ExcelUtil<GcProgressProjectEnd>(GcProgressProjectEnd.class);
        util.exportExcel(response, list, "项目进度控制--项目结束数据");
    }

    /**
     * 获取项目进度控制--项目结束详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectschedule:projectEnd:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(gcProgressProjectEndService.selectGcProgressProjectEndById(id));
    }

    /**
     * 新增项目进度控制--项目结束
     */
    @PreAuthorize("@ss.hasPermi('projectschedule:projectEnd:add')")
    @Log(title = "项目进度控制--项目结束", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcProgressProjectEnd gcProgressProjectEnd) {
        return success(gcProgressProjectEndService.insertGcProgressProjectEnd(gcProgressProjectEnd));
    }

    /**
     * 修改项目进度控制--项目结束
     */
    @PreAuthorize("@ss.hasPermi('projectschedule:projectEnd:edit')")
    @Log(title = "项目进度控制--项目结束", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcProgressProjectEnd gcProgressProjectEnd) {
        return toAjax(gcProgressProjectEndService.updateGcProgressProjectEnd(gcProgressProjectEnd));
    }

    /**
     * 删除项目进度控制--项目结束
     */
    @PreAuthorize("@ss.hasPermi('projectschedule:projectEnd:remove')")
    @Log(title = "项目进度控制--项目结束", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id) {
        return toAjax(gcProgressProjectEndService.deleteGcProgressProjectEndById(id));
    }
}
